using AutoMapper;
using lwzlz.Core;
using lwzlz.Core.Repository;

namespace lwzlz.Application.System
{
    public class UserLogService
    {
        private readonly IRepository<UserLog> _repository;

        public UserLogService()
        {
            _repository = new Repository<UserLog>();
        }

        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public UserLog Get(int id)
        {
            return _repository.Get(id);
        }

        /// <summary>
        /// 获取输出对象
        /// </summary>
        /// <typeparam name="TDto"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        public TDto Get<TDto>(int id) where TDto : class, new()
        {
            var entity = Get(id);
            return Mapper.Map<TDto>(entity);
        }

        public bool Add(UserLog model)
        {
            return _repository.Insert(model) > 0 ? true : false;
        }
    }
}

